import { BasicColumn } from '@/components/Table';
import { FormSchema } from '@/components/Table';
import _ from '@/utils/math';
export const columns: BasicColumn[] = [
  {
    title: '表注释',
    dataIndex: 'tableComment',
    width: 100,
  },
  {
    title: '表名',
    dataIndex: 'tableName',
    width: 200,
  },
  {
    title: '包名',
    dataIndex: 'packageName',
    width: 140,
  },
  {
    title: '模块名',
    dataIndex: 'moduleName',
    width: 140,
  },
  {
    title: '作者',
    dataIndex: 'authorName',
    width: 200,
  },
  {
    title: '类名',
    dataIndex: 'className',
    width: 140,
  },
  {
    title: '是否移除表前缀',
    dataIndex: 'tablePrefix',
    width: 140,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 140,
  },
  {
    title: '备注',
    dataIndex: 'remark',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '名称',
    component: 'Input',
    colProps: { span: 8 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: '',
    component: 'Input',
    show: false,
  },
  {
    field: 'dataSource',
    label: '数据源',
    required: true,
    component: 'ApiSelect',
    defaultValue: 'default',
  },
  {
    field: 'tableName',
    label: '表名',
    required: true,
    component: 'ApiSelect',
  },
  {
    field: 'tableComment',
    label: '功能名',
    required: true,
    component: 'Input',
  },
  {
    field: 'authorName',
    label: '作者名',
    required: true,
    component: 'Input',
  },

  {
    field: 'menuPid',
    label: '上级菜单',
    component: 'TreeSelect',
    required: true,
    componentProps: {
      fieldNames: {
        title: 'title',
        key: 'id',
        value: 'id',
      },
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'frontDir',
    label: '前端目录',
    required: true,
    component: 'Input',
  },
  {
    field: 'serverDir',
    label: '服务端目录',
    required: true,
    component: 'Input',
  },
  {
    field: 'className',
    label: '类名',
    required: true,
    component: 'Input',
  },
  {
    field: 'packageName',
    label: '包名',
    required: true,
    component: 'Input',
  },
  {
    field: 'moduleName',
    label: '模块名',
    required: true,
    component: 'Input',
  },
  {
    field: 'actionType',
    label: '页面crud操作',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      mode: 'multiple',
      dictCode: 'code_gen_actions',
    },
    colProps: {
      span: 12,
    },
  },
  {
    field: 'di',
    label: '表单基础配置',
    component: 'Divider',
    colProps: { span: 24 },
  },
  {
    label: '表单容器类型',
    field: 'editFormType',
    component: 'ApiRadioGroup',
    defaultValue: 'modal',
    required: true,
    componentProps: {
      dictCode: 'editFormType',
    },
  },
  {
    label: '查询span',
    field: 'queryFormSpan',
    component: 'InputNumber',
    defaultValue: 12,
    componentProps: {
      min: 1,
      max: 24,
    },
  },
  {
    label: '编辑span',
    field: 'editFormSpan',
    component: 'InputNumber',
    defaultValue: 12,
    componentProps: {
      min: 1,
      max: 24,
    },
  },
  {
    label: '编辑表单宽度',
    field: 'editModalWidth',
    component: 'InputNumber',
    helpMessage: '百分比',
    defaultValue: 50,
    componentProps: {
      min: 1,
      max: 100,
    },
  },
];

export const columnConfigColumns: BasicColumn[] = [
  {
    title: '列名',
    dataIndex: 'columnName',
    width: 100,
    fixed: 'left',
    slots: {
      customRender: 'columnName',
    },
  },
  {
    title: '字段描述',
    dataIndex: 'columnComment',
    fixed: 'left',
    width: 140,
    slots: {
      customRender: 'columnComment',
    },
  },
  {
    title: 'java' + '类型',
    dataIndex: 'javaType',
    width: 240,
    fixed: 'left',
    slots: {
      customRender: 'javaType',
    },
  },
  {
    title: '查询条件',
    children: [
      {
        title: '是否查询条件',
        dataIndex: 'isSearch',
        width: 140,
        slots: {
          customRender: 'isSearch',
        },
      },
      {
        title: '查询方式',
        dataIndex: 'searchType',
        width: 140,
        slots: {
          customRender: 'searchType',
        },
      },
      {
        title: '是否必填',
        dataIndex: 'isSearchRequired',
        width: 140,
        slots: {
          customRender: 'isSearchRequired',
        },
      },
    ],
  },
  {
    title: '编辑表单',
    children: [
      {
        title: '组件类型',
        dataIndex: 'componentType',
        width: 200,
        slots: {
          customRender: 'componentType',
        },
      },
      {
        title: '字典code',
        width: 300,
        slots: {
          customRender: 'formDictCode',
        },
      },
      {
        title: '是否必填',
        dataIndex: 'isFormRequired',
        width: 140,
        slots: {
          customRender: 'isFormRequired',
        },
      },
      {
        title: '正则验证',
        dataIndex: 'formRules',
        width: 140,
        slots: {
          customRender: 'formRules',
        },
      },
      {
        title: '是否可新增',
        dataIndex: 'isFormAdd',
        width: 140,
        slots: {
          customRender: 'isFormAdd',
        },
      },
      {
        title: '是否可修改',
        dataIndex: 'isFormEdit',
        width: 140,
        slots: {
          customRender: 'isFormEdit',
        },
      },
    ],
  },
  {
    title: '查询列表',
    children: [
      {
        title: '列表字段(DTO)',
        dataIndex: 'isTable',
        width: 140,
        slots: {
          customRender: 'isTable',
        },
      },
    ],
  },
];
